package dontCare.gwtester.client.puzzlers;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.TooManyListenersException;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

import dontCare.gwtester.client.tool.SourceUrl;
import dontCare.gwtester.client.tool.UnitWidget;

public class Album5 extends UnitWidget{
	private static Album5UiBinder uiBinder = GWT.create(Album5UiBinder.class);
	interface Album5UiBinder extends UiBinder<Widget, Album5> {}
	
	@UiField Label indecision;
	@UiField Label arcane;
	
	public Album5() {
		initWidget(uiBinder.createAndBindUi(this));
		indecision.setText(""+indecision());
		exceptionallyArcane();
	}
	
	private boolean indecision() {
		try{
			return true;
		}finally{
			return false;			
		}
	}

	//Puzzler 37
	interface Type1{ void f() throws IOException; }
	interface Type2{ void f() throws TooManyListenersException; }
	interface Type3{}
	class Arcane3 implements Type3{
		public void f(){
			arcane.setText("Hello world");
		}
	}
	private void exceptionallyArcane() {
		new Arcane3().f();
	}
	//
	
	@Override
	public List<String> getSourceUrl() {
		ArrayList<String> result = new ArrayList<String>();
		result.add(SourceUrl.genJava(Album5.class));
		result.add(SourceUrl.genUiXml(Album5.class));
		return result;
	}

	@Override
	public HTML getDescription() {
		return new HTML(
			"《Java Puzzlers》 Chapter 5 puzzler 集合。" +
			"<br />Puzzler 37：Arcane1 無法 comple，故跳過；Arcane2 沒特殊意義，也跳過。Arcane3 由於 GWT 不提供 CloneNotSupportedException 與 InterruptedException，" +
			"因此改成也是直接 extends java.lang.Exception 的 IOException 與 TooManyListenersException。"
		);
	}

	@Override
	public String getName() {
		return "CH.5 Album";
	}
}